package cn.gxa.j229.bug.finance.controller.loanuser;

import cn.gxa.j229.bug.finance.pojo.Audit;
import cn.gxa.j229.bug.finance.pojo.MoneyRecord;
import cn.gxa.j229.bug.finance.service.loanuser.MoneyRecordService;
import cn.gxa.j229.bug.finance.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author: fenglin
 * @Date:2020/9/28 14:21
 * @Version 1.0
 */
@Controller
@RequestMapping("/moneyRecord")
public class MoneyRecordController {
    @Autowired
    MoneyRecordService moneyRecordService;

    JsonResult jsonResult=new JsonResult();
    @PostMapping("/selectAll")
    @ResponseBody
    public Map selectAll(@RequestBody MoneyRecord moneyRecord){
        Integer limit = moneyRecord.getLimit();
        Integer page = moneyRecord.getPage();
        System.out.println(limit);
        System.out.println(page);
        List<Map<String, String>> selectAll = moneyRecordService.selectAll(moneyRecord);
        int count=moneyRecordService.selectAllCount(moneyRecord);
        jsonResult.put("count",count);

        jsonResult.setData(selectAll);
        jsonResult.setMsg("成功");
        jsonResult.setCode("200");
        return jsonResult.getValues();
    }
    @PostMapping("/selectKey")
    @ResponseBody
    public Map selectKey(@RequestBody MoneyRecord moneyRecord){


        List<Map<String, String>> selectKey = moneyRecordService.selectKey(moneyRecord);
        int count = moneyRecordService.selectKeyCount(moneyRecord);
        jsonResult.put("count",count);

        jsonResult.setData(selectKey);
        jsonResult.setMsg("成功");
        jsonResult.setCode("200");
        return jsonResult.getValues();
    }

}
